import { createRouter, createWebHashHistory } from 'vue-router'

import Layout from '@/views/Layout/Layout.vue'
import Home from '@/views/Home/Home.vue'

const routes = [
  {
    path: '/', // 直接访问
    name: 'layout',
    component: Layout,
    children: [
      {
        path: '', // /#/ path为空，默认展示这个组件
        name: 'home',
        component: Home
      },
      { path: '/category/:id', name: 'category', component: () => import('@/views/Category/Category.vue') },
      { path: '/goods/:id', name: 'goods', component: () => import('@/views/goods/goods.vue') },
      { path: '/cart', name: 'cart', component: () => import('@/views/Cart/Cart.vue') },
      { path: '/settlement', name: 'settlement', component: () => import('@/views/Settlement/SelttleIndex.vue') },
      { path: '/pay', name: 'pay', component: () => import('@/views/Pay/Pay.vue') },
      { path: '/pay/callback', name: 'callback', component: () => import('@/views/Pay/Callback.vue') }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login/Login.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
